package sk.openit.java.io;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author johny
 *
 */
public class CopyBytes {
    public static void main(String[] args) {
        FileInputStream in = null;
        FileOutputStream out = null;
        try {
        	File inputFile = new File("test-files/xanadu.txt");
            in = new FileInputStream(inputFile);
            out = new FileOutputStream("test-files/outagain.txt");
            int c;

            while ((c = in.read()) != -1) {
                out.write(c);
            }
        } catch(IOException e) {
        	e.printStackTrace();
        } finally {
            if (in != null) {
                try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
            }
            if (out != null) {
                try {
					out.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
            }
        }
    }
}
